package cn.ecut.service.impl;


import cn.ecut.dao.FangjianDao;
import cn.ecut.model.Fangjian;
import cn.ecut.model.Loudong;
import cn.ecut.model.Taofang;
import cn.ecut.service.FangjianService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.DecimalFormat;
import java.util.List;

@Service
public class FangjianServiceimpl implements FangjianService {

    @Autowired
    private FangjianDao fangjianDao;
    @Override
    public List<Fangjian> selectAll() {
        return fangjianDao.selectAll();
    }

    @Override
    public int selectAllcount() {
        return fangjianDao.selectAllcount();
    }

    @Override
    public Loudong selectLoudong(String loudongbianma) {
        return fangjianDao.selectLoudong(loudongbianma);
    }

    @Override
    public Taofang selectTaofang(String taofangbianma) {
        return fangjianDao.selectTaofang(taofangbianma);
    }

    @Override
    public int updateQiyong(Fangjian fangjian) {
        return fangjianDao.updateQiyong(fangjian);
    }

    @Override
    public String getfangjianBianma() {
        DecimalFormat decimalFormat=new DecimalFormat("00000");
        String s = fangjianDao.selectThelast();
        s=s.substring(2);
        System.out.println(s);
        int i=Integer.parseInt(s)+1;
        String k=decimalFormat.format(i);
        String fangjianBianma = "FJ"+k;
        System.out.println(fangjianBianma);
        return fangjianBianma;
    }

    @Override
    public int insert(Fangjian fangjian) {
        return fangjianDao.insert(fangjian);
    }

    @Override
    public int updateByPrimaryKey(Fangjian fangjian) {
        return fangjianDao.updateByPrimaryKey(fangjian);
    }

    @Override
    public int deleteByPrimaryKey(String fangjianbianma) {
        return fangjianDao.deleteByPrimaryKey(fangjianbianma);
    }

    @Override
    public List<Fangjian> advanceSelect(String s) {
        return fangjianDao.advanceSelect(s);
    }
}
